﻿<table class="unit-table forum-topic">
    <thead>
        <tr>
            <th>@T(Res.Name("Topic"))</th>
            <th>@T(Res.Name("PostCount"))</th>
            <th>@T(Res.Name("LastPost"))</th>
        </tr>
    </thead>
    <tbody>
    @if((Model.Items as IEnumerable<dynamic>).Any())
    {
        foreach(var i in Model.Items)
        {
            <tr class="unit forum-topic @(JDM.HasFlags(i.Flags, "Announcement") ? "announcement" : String.Empty) @(JDM.HasFlags(i.Flags, "General") ? "general" : String.Empty) @(JDM.HasFlags(i.Flags, "Question") ? "question" : String.Empty)">
                <td>
                    <h5><a href="@Url.Action(Loc.Act("Show").Ctrl("Topic").Set(new
                    {
                        id = JDM.Int32(i.EntityID)
                    }).Localized())">@JDM.String(i.Title)</a></h5>
                    <a href="@Url.Action(Loc.Act("Show").Ctrl("Account").NoArea().Set(new
                    {
                        id = JDM.Int32(i.Member.Account.EntityID)
                    }).Localized())">@T(Res.In("Common").Of("Expr").Name("By"), JDM.String(i.Member.Account.Username))</a>
                    @Svc.DateTimeRel((DateTime)JDM.DateTime(i.CreatedOn))
                </td>
                <td>@JDM.Int32(i.PostCount)</td>
                <td>
                @if(i.LastPost != null)
                {
                    <a href="@Url.Action(Loc.Act("Show").Ctrl("Account").NoArea().Set(new
                    {
                        id = JDM.Int32(i.LastPost.Member.Account.EntityID)
                    }).Localized())">@T(Res.In("Common").Of("Expr").Name("By"), JDM.String(i.LastPost.Member.Account.Username))</a><br/>
                    @Svc.DateTimeRel((DateTime)JDM.DateTime(i.LastPost.CreatedOn))
                }
                </td>
            </tr>  
        }
    }
    else
    {
        <tr>
            <td class="empty" colspan="3"><span>@T(Res.In("Common").Of("Expr").Name("NoData"))</span></td>
        </tr>
    }
    </tbody>
</table>